import 'package:flutter/material.dart';
import 'package:flutter_application_test/calendar/widgets/notification.dart';

/// 天小部件
class DayWidget extends StatelessWidget {
  /// 高度
  final double height;

  /// day
  final int day;

  /// 是否是今天
  final bool isToday;

  /// 是否是周末
  final bool isWeekend;

  /// 上个月、下个月文本颜色
  final Color noDayInMonthColor;

  /// 是否被选中
  final bool isSelected;

  const DayWidget({
    Key? key,
    required this.day,
    this.height = 44,
    this.isToday = false,
    this.isWeekend = false,
    this.isSelected = false,
    this.noDayInMonthColor = Colors.grey,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () => CalendarNotification(selectDay: day).dispatch(context),
      child: Container(
        width: MediaQuery.of(context).size.width / 7 - 10,
        height: height,
        alignment: Alignment.center,
        margin: const EdgeInsets.symmetric(vertical: 5, horizontal: 5),
        decoration: isSelected
            ? BoxDecoration(
                color: Colors.transparent,
                border: Border.all(color: Colors.blue, width: 2),
                borderRadius: BorderRadius.circular(8),
              )
            : const BoxDecoration(
                color: Colors.transparent,
              ),
        child: Text(
          day == -1 ? '' : '$day',
          style: TextStyle(
            color: isWeekend ? Colors.grey : Colors.black,
            fontSize: 15,
            fontWeight: FontWeight.bold,
          ),
        ),
      ),
    );
  }
}
